package com.lsa.letcode.the23.mergeKsortedLists;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		List<List<Integer>> lists = new ArrayList<List<Integer>>();
		lists.addAll(Arrays.asList(Arrays.asList(1),Arrays.asList(2), Arrays.asList(3), Arrays.asList(4), Arrays.asList(5)/*, Arrays.asList(6), Arrays.asList(7), Arrays.asList(8)*/));
		int end = lists.size() - 1;
		
		while (end > 0) {
			int begin = 0;
			while (begin < end) {
				List<Integer> res = new ArrayList<>();
				res.addAll(lists.get(begin));
				res.addAll(lists.get(end));
				lists.set(begin, res);
				System.out.println(String.format("%s %s", begin, end));
				begin++;
				end--;
			}
			
//			for (int i = 0; i < lists.size(); i++) {
//				System.out.print(String.format("%s ", lists.get(i).size()));
//			}
//			System.out.println();
		}
		Collections.sort(lists.get(0));
		System.out.println(lists.get(0));
	}
}
